#include "audio.h"

Audio::Audio( QWidget * parent, Qt::WFlags f) 
	: QDialog(parent, f)
{
#ifdef Q_WS_WIN
	path = QCoreApplication::applicationDirPath();
#else 
	path = QDir::homePath ()+"/.qalarm";
#endif	
	setupUi(this);		
	init();
	connect(audioSelect, SIGNAL(clicked()), this, SLOT(load()));
	connect(audioSave, SIGNAL(clicked()), this, SLOT(save()));
	setWindowIcon(QIcon(path+"/images/alarm.png"));
}

void Audio::save()
{	
	Utils utils;
	utils.saveFile(path+"/data/audio",audioEdit->text());
	hide();			
	Utils::changed = true;		
}

void Audio::load()
{
	audioEdit->setText(QFileDialog::getOpenFileName(this,tr("Open File"),".",tr("audios (*.mp3 *.wma *.ogg *.wave *.midi)")));
}

void Audio::init()
{
	Utils utils;
	audioEdit->setText(utils.readFile(path+"/data/audio"));		
}
